<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    function Parent(m){
    }
    Parent.prototype.show = function(m){
        this.message = m;
        console.log(this.message);
    }

    function Parent2(){}
    Parent2.prototype.init = function(m){
        console.log("这是Parent2的方法");
    }

    function Child(m){}

    // 浅拷贝
    // Child.prototype = Parent.prototype;
    // 深拷贝
    for(let i in Parent.prototype){
        Child.prototype[i] = Parent.prototype[i];
    }
    for(let i in Parent2.prototype){
        Child.prototype[i] = Parent2.prototype[i];
    }

    Child.prototype.show = function(){
        console.log("改写之后的Child的show")
    }

    const p = new Parent();
    p.show("hello world");
    console.log(p.message);
    console.log(p);

    const c = new Child();
    c.show("hello 世界");
    console.log(c.message);
    console.log(c);
    c.init();


</script>
</html>